<body>
<p>Test that MessagePort close event gets delivered (without crashing) even if the channel object is garbage collected.</p>
<pre id=log></pre>
<script src="../../resources/gc.js"></script>
<script>

function log(message)
{
    document.getElementById("log").innerHTML += message + "<br>";
}

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

var channel = new MessageChannel;

gc();
channel.port1.start();
channel.port2.postMessage("msg");

gc();
channel.port1.close();
channel.port2.close();
gc();

setTimeout(function() {
    log("DONE");
    gc();
    if (window.testRunner)
        testRunner.notifyDone();
}, 0);
channel = new MessageChannel;
gc();

</script>
</body>
